#include "../include/WebPageQuery.hpp"
#include "../include/Configuration.hpp"

#include <nlohmann/json.hpp>

using std::string;
using std::to_string;

using Json = nlohmann::json;

Configuration* Configuration::pCnof = nullptr;
Configuration::AutoRelease Configuration::release;


int test(){
    WebPageQuery wbq;

    cout << "begin loadLibrary" << endl;
    wbq.loadLibrary();
    cout << "end loadLibrary" << endl;
    string s("美食");
    wbq.doQuery(s);

    return 0;
}

int testJson(){
    WebPageQuery wbq;
    Json root;

    cout << "begin loadLibrary" << endl;
    wbq.loadLibrary();
    cout << "end loadLibrary" << endl;
    string s("量子计算机");
    root = Json::parse(wbq.doQuery(s));
    int N = root.size();

    cout << endl << endl << endl;
    cout << "json内容: " << endl;
    for(int idx = 1; idx <= N; ++idx){
        cout << root[to_string(idx)]["title"].get<string>() << endl;
        cout << root[to_string(idx)]["url"].get<string>() << endl;
        cout << root[to_string(idx)]["summary"].get<string>() << endl;
    }

}

int main(){
    test();
    /* testJson(); */
    return 0;
}
